package com.itheima.d16_stringBuilder;

public class Test3 {
    public static void main(String[] args) {
        System.out.println(getArrayData(new int[]{1, 2, 3, 5}));
    }

    public static String getArrayData(int[] arr) {
        if (arr == null) return null;

        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) sb.append(arr[i]);
            else sb.append(arr[i]).append(",");
        }
        sb.append("]");
        return sb.toString();
    }
}
